package com.bawei.product.domain.vo;

import com.alibaba.fastjson2.JSONObject;
import com.bawei.common.core.utils.bean.BeanUtils;
import com.bawei.product.domain.req.ProductSku;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Set;

@Data
@ApiModel(description = "ProductSku entity")
public class ProductSkuVo extends HashMap {

    @ApiModelProperty(value = "SKU ID")
    private Long id;

    @ApiModelProperty(value = "销售价格")
    private BigDecimal salePrice;

    @ApiModelProperty(value = "促销价格")
    private BigDecimal promotionPrice;

    @ApiModelProperty(value = "库存")
    private Integer stock;

    @ApiModelProperty(value = "预警库存")
    private Integer stockAlert;

    @ApiModelProperty(value = "商品ID")
    private Long productId;

    @ApiModelProperty(value = "SKU背景图地址")
    private String bgImg;

    @ApiModelProperty(value = "是否删除 0-不删除 1-删除")
    private Integer isDelete;

    @ApiModelProperty(value = "创建人")
    private Long createBy;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    public static void main(String[] args) {
        ProductSkuVo productSkuReq = new ProductSkuVo();
        productSkuReq.put("1", 1);
        productSkuReq.put("2",1);
        productSkuReq.setId(1l);
        ProductSku productSku = new ProductSku();
        BeanUtils.copyProperties(productSkuReq, productSku);

        String jsonString = JSONObject.toJSONString(productSku);
        HashMap hashMap = JSONObject.parseObject(jsonString, HashMap.class);
        Set set1 = productSkuReq.keySet();
        Set set2 = hashMap.keySet();
        set1.forEach(key -> {
            if (set2.contains(key)){
                set1.remove(key);
            }
        });
        System.out.println(JSONObject.toJSONString(set1));


        System.out.println(JSONObject.toJSONString(productSkuReq.keySet()));
    }
}